/* 
包含n个接口请求函数的模块
每个函数返回的都是promise
*/
import ajax from './ajax'
const base = '/api'

// [1、根据经纬度获取位置详情]
export const reqAddress = (geohashe) => ajax({
    url: base + `/position/${geohashe}`,
    method: 'get',
})

// [2、获取食品分类列表]
export const reqFoodsList = () => ajax({
    url: base + '/index_category',
    method: 'get',
    headers:{
        needToken: true
    }
})

// [3、根据经纬度获取商铺列表]
export const reqShopsList = (latitude, longitude) => ajax({
    url: base + '/shops',
    method: 'get',
    params:{
        latitude,
        longitude
    },
    headers:{
        needToken: true
    }
})


// [4、根据经纬度和关键字搜索商铺列表]
export const reqSearchShopList = (keyword,geohash) => ajax({
    url: base + '/search_shops',
    method: 'get',
    params:{
        geohash,
        keyword
    }
})


// [6、用户名密码登陆]
export const reqLoginByUsername = (name,pwd,captcha) => ajax({
    url: base + '/login_pwd',
    method: 'post',
    data:{
        name,
        pwd,
        captcha
    }
})

// [7、发送短信验证码]
export const reqSMSCode = (phone) => ajax({
    url: base + '/sendcode',
    method: 'get',
    params:{
        phone
    }
})


// [8、手机号验证码登陆]
export const reqLoginBySMS = (phone, code) => ajax({
    url: base + '/login_sms',
    method: 'post',
    data:{
        phone,
        code
    }
})

// [9、根据会话获取用户信息]
export const reqAutoLogin = () => ajax({
    url: base + '/auto_login',
    method: 'get',
    headers:{
        needToken: true
    }
})


/**
 * 获取商家信息
 */
export const reqShopInfo = () => ajax('/shop_merchants')

/**
 * 获取商家评价数组
 */
export const reqShopScore = () => ajax('/shop_score')

/**
 * 获取商家商品数组
 */
export const reqShopGoods = () => ajax('/shop_goods')